makes=[[0,0,4,0,0,1],
       [7,5,1,0,0,0]]
anss=[]
for need in makes:
    i=6
    ans=0
    while need!=[0,0,0,0,0,0]:
        while need[i-1]==0:
            i-=1
        maxl=6-i
        num=0
        need[i-1]-=1
        use=i*i
        try:
            num=(36-use)/maxl*maxl
        except ZeroDivisionError:
            pass
        while maxl>0:
            if need[maxl-1]>=num:
                need[maxl-1]-=num
                break
            else:
                use+=need[maxl-1]*maxl*maxl
                num=(36-use)/maxl*maxl
                need[maxl-1]=0
                maxl-=1
        ans+=1
        print(need)
        print(ans)
    anss.append(ans)
print(anss)